import friendApi from '@/api/friend.js'
import pinia from "@/store/index";
import {
	useloginStore
}
from "@/store/login";
const loginStore = useloginStore(pinia);
/** 
 * 实名认证
 * @param {*} data
 */
export function useSaveRealInfo(data) {
	uni.showLoading({
		title: '保存中',
		mask: true
	})
	friendApi.updateIdentity(data).then(res => {
		if (res.code === 0) {
			const app = getApp();

			const userInfo = uni.getStorageSync("userInfo");
			console.log(userInfo, 'userInfo');
			for (let key in data) {
				userInfo[key] = data[key]
				app.globalData.modifyData = {
					type: key,
					value: data[key],
				};
			}

			loginStore.login(userInfo)
			uni.showToast({
				title: '保存成功',
				icon: 'none'
			})
			setTimeout(() => {
				uni.navigateBack()
			}, 1000)
		}
		else {
			uni.showToast({
				title: res.msg,
				icon: 'none'
			})
		}

	})
}